package com.xbongbong.parent.interfaces;

import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.vo.FormDataAddVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.domain.entity.ReRollBackEntity;
import com.xbongbong.pro.formdata.pojo.vo.BeforeSaveVO;
import com.xbongbong.pro.formdata.pojo.vo.SaveVO;

import java.util.List;

/**
 *
 * @author 魏荣杰
 * @date 2020/12/30 10:14
 * @since
 * @version
 */
public interface FormDataService<F, D> extends BusinessAddBeforeService<F, D>, BusinessAddAfterService<F, D>, FormDataWorkflowService<F, D> {


    /**
     * 新建数据
     * @param formDataAddDTO
     * @return
     * @throws XbbException
     */
    FormDataAddVO addAndImport(FormDataAddDTO formDataAddDTO) throws XbbException;

    /**
     * 新建数据
     * @param formDataAddDTO
     * @return
     * @throws XbbException
     */
    FormDataAddVO add(FormDataAddDTO formDataAddDTO) throws XbbException;

    /**
     * 导入数据
     * @param formDataAddDTO
     * @return
     * @throws XbbException
     */
    FormDataAddVO importData(FormDataAddDTO formDataAddDTO) throws XbbException;



    /**
     * 新建数据，但是只会调用新建和新建之后的方法
     * @param beforeSaveVO
     * @param formDataAddDTO
     * @param paasFormEntityExt
     * @param formData
     * @return
     * @throws XbbException
     */
    FormDataAddVO addNoValidate(BeforeSaveVO beforeSaveVO, FormDataAddDTO formDataAddDTO, F paasFormEntityExt , D formData) throws XbbException;
    /**
     * 构造工厂
     * @return
     */
    List<Integer> businessList();

    /**
     * 保存之前的校验与解析操作
     * @param formDataSaveDTO
     * @author 吴峰
     * @date 2020/12/30 16:49
     * @return
     * @throws XbbException
     */
    @Deprecated
    BeforeSaveVO beforeSave(FormDataAddDTO formDataSaveDTO) throws XbbException;

    /**
     * 新建保存入口
     * @param formDataAddDTO
     * @param beforeSaveVO
     * @return com.xbongbong.pro.formdata.pojo.vo.SaveVO
     * @author 吴峰
     * @date 2021/2/23 15:51
     * @throws XbbException
     */
    SaveVO save(FormDataAddDTO formDataAddDTO, BeforeSaveVO beforeSaveVO, F paasFormEntity, D formData) throws XbbException;

    /**
     * save回滚es
     * @param dataId
     * @param corpid
     * @param saasMark
     * @param businessType
     * @throws XbbException
     */
    void saveRollBack(Long dataId, String corpid, Integer saasMark, Integer businessType) throws XbbException;

    /**
     * 新建保存之后的逻辑，保存日志、触发业务规则等操作
     * @param formDataAddDTO
     * @param beforeSaveVO 保存之前的方法返回的数据
     * @param saveVO 保存方法返回的数据
     * @return com.xbongbong.pro.formdata.pojo.vo.SaveVO
     * @author 吴峰
     * @date 2021/2/23 15:51
     * @throws XbbException
     */
    FormDataAddVO afterSave(FormDataAddDTO formDataAddDTO, BeforeSaveVO beforeSaveVO, SaveVO saveVO, F paasFormEntity, D formData) throws XbbException;

    /**
     * afterSave回滚es
     * @param newPaasFormDataEntity
     * @param dataId
     * @param corpid
     * @param saasMark
     * @param businessType
     * @param reRollBackEntity
     */
    void afterSaveRollBack(D newPaasFormDataEntity, Long dataId, String corpid, Integer saasMark, Integer businessType, ReRollBackEntity reRollBackEntity) throws XbbException;

}
